.class public Lcom/nemustech/regina/widgets/missednoti/CallLogReader;
.super Ljava/lang/Object;
.source "CallLogReader.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/nemustech/regina/widgets/missednoti/CallLogReader$1;,
        Lcom/nemustech/regina/widgets/missednoti/CallLogReader$CallLogReaderPhoneStateListener;,
        Lcom/nemustech/regina/widgets/missednoti/CallLogReader$CallLogInfo;
    }
.end annotation


# static fields
.field private static final CALL_LOG_CONTENT_URI:Landroid/net/Uri; = null

.field private static final CALL_LOG_READ:I = 0x0

.field private static final CALL_LOG_TYPE_INCOMING:I = 0x1

.field private static final CALL_LOG_TYPE_MISSED:I = 0x3

.field private static final CALL_LOG_TYPE_OUTGOING:I = 0x2

.field private static final CALL_LOG_UNREAD:I = 0x1

.field private static final PROJECTION_CALL_LOG_COUNT:[Ljava/lang/String; = null

.field private static final TAG:Ljava/lang/String; = "CallLogReader"


# instance fields
.field private mPhoneStateListener:Lcom/nemustech/regina/widgets/missednoti/CallLogReader$CallLogReaderPhoneStateListener;

.field private mReginaLauncher:Lcom/nemustech/regina/ReginaLauncher;

.field private mTelManager:Landroid/telephony/TelephonyManager;


# direct methods
.method static constructor <clinit>()V
    .locals 3

    .prologue
    .line 22
    sget-object v0, Landroid/provider/CallLog$Calls;->CONTENT_URI:Landroid/net/Uri;

    sput-object v0, Lcom/nemustech/regina/widgets/missednoti/CallLogReader;->CALL_LOG_CONTENT_URI:Landroid/net/Uri;

    .line 31
    const/4 v0, 0x1

    new-array v0, v0, [Ljava/lang/String;

    const/4 v1, 0x0

    const-string v2, "_id"

    aput-object v2, v0, v1

    sput-object v0, Lcom/nemustech/regina/widgets/missednoti/CallLogReader;->PROJECTION_CALL_LOG_COUNT:[Ljava/lang/String;

    return-void
.end method

.method public constructor <init>(Lcom/nemustech/regina/ReginaLauncher;)V
    .locals 0
    .parameter "reginaLauncher"

    .prologue
    .line 38
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 39
    iput-object p1, p0, Lcom/nemustech/regina/widgets/missednoti/CallLogReader;->mReginaLauncher:Lcom/nemustech/regina/ReginaLauncher;

    .line 40
    return-void
.end method


# virtual methods
.method public getMissedCallLogCount()I
    .locals 9

    .prologue
    .line 91
    const-string v3, "new=1 AND type=3"

    .line 92
    .local v3, where:Ljava/lang/String;
    const/4 v6, 0x0

    .line 93
    .local v6, c:Landroid/database/Cursor;
    const/4 v7, 0x0

    .line 95
    .local v7, count:I
    :try_start_0
    iget-object v0, p0, Lcom/nemustech/regina/widgets/missednoti/CallLogReader;->mReginaLauncher:Lcom/nemustech/regina/ReginaLauncher;

    sget-object v1, Landroid/provider/CallLog$Calls;->CONTENT_URI:Landroid/net/Uri;

    sget-object v2, Lcom/nemustech/regina/widgets/missednoti/CallLogReader;->PROJECTION_CALL_LOG_COUNT:[Ljava/lang/String;

    const/4 v4, 0x0

    const/4 v5, 0x0

    invoke-virtual/range {v0 .. v5}, Lcom/nemustech/regina/ReginaLauncher;->managedQuery(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v6

    .line 96
    invoke-interface {v6}, Landroid/database/Cursor;->getCount()I
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result v7

    .line 100
    if-eqz v6, :cond_0

    invoke-interface {v6}, Landroid/database/Cursor;->close()V

    .line 102
    :cond_0
    :goto_0
    return v7

    .line 97
    :catch_0
    move-exception v0

    move-object v8, v0

    .line 98
    .local v8, e:Ljava/lang/Exception;
    :try_start_1
    invoke-virtual {v8}, Ljava/lang/Exception;->printStackTrace()V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 100
    if-eqz v6, :cond_0

    invoke-interface {v6}, Landroid/database/Cursor;->close()V

    goto :goto_0

    .end local v8           #e:Ljava/lang/Exception;
    :catchall_0
    move-exception v0

    if-eqz v6, :cond_1

    invoke-interface {v6}, Landroid/database/Cursor;->close()V

    :cond_1
    throw v0
.end method

.method public getMissedCallLogList(Ljava/util/List;)V
    .locals 12
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/List",
            "<",
            "Lcom/nemustech/regina/widgets/missednoti/CallLogReader$CallLogInfo;",
            ">;)V"
        }
    .end annotation

    .prologue
    .line 62
    .local p1, callLogList:Ljava/util/List;,"Ljava/util/List<Lcom/nemustech/regina/widgets/missednoti/CallLogReader$CallLogInfo;>;"
    const/4 v6, 0x0

    .line 64
    .local v6, c:Landroid/database/Cursor;
    :try_start_0
    sget-object v1, Landroid/provider/CallLog$Calls;->CONTENT_URI:Landroid/net/Uri;

    .line 65
    .local v1, callLogUri:Landroid/net/Uri;
    iget-object v0, p0, Lcom/nemustech/regina/widgets/missednoti/CallLogReader;->mReginaLauncher:Lcom/nemustech/regina/ReginaLauncher;

    const/4 v2, 0x0

    const/4 v3, 0x0

    const/4 v4, 0x0

    const/4 v5, 0x0

    invoke-virtual/range {v0 .. v5}, Lcom/nemustech/regina/ReginaLauncher;->managedQuery(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v6

    .line 66
    invoke-interface {v6}, Landroid/database/Cursor;->getCount()I
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result v0

    if-gtz v0, :cond_1

    .line 86
    if-eqz v6, :cond_0

    invoke-interface {v6}, Landroid/database/Cursor;->close()V

    .line 88
    .end local v1           #callLogUri:Landroid/net/Uri;
    :cond_0
    :goto_0
    return-void

    .line 67
    .restart local v1       #callLogUri:Landroid/net/Uri;
    :cond_1
    :try_start_1
    invoke-interface {v6}, Landroid/database/Cursor;->moveToFirst()Z

    .line 69
    :cond_2
    new-instance v7, Lcom/nemustech/regina/widgets/missednoti/CallLogReader$CallLogInfo;

    const/4 v0, 0x0

    invoke-direct {v7, p0, v0}, Lcom/nemustech/regina/widgets/missednoti/CallLogReader$CallLogInfo;-><init>(Lcom/nemustech/regina/widgets/missednoti/CallLogReader;Lcom/nemustech/regina/widgets/missednoti/CallLogReader$1;)V

    .line 70
    .local v7, callLogInfo:Lcom/nemustech/regina/widgets/missednoti/CallLogReader$CallLogInfo;
    const-string v0, "type"

    invoke-interface {v6, v0}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v0

    invoke-interface {v6, v0}, Landroid/database/Cursor;->getInt(I)I

    move-result v8

    .line 71
    .local v8, callLogType:I
    const-string v0, "new"

    invoke-interface {v6, v0}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v0

    invoke-interface {v6, v0}, Landroid/database/Cursor;->getInt(I)I

    move-result v9

    .line 72
    .local v9, callNew:I
    const/4 v0, 0x1

    if-ne v9, v0, :cond_3

    const/4 v0, 0x3

    if-ne v8, v0, :cond_3

    .line 73
    iput v8, v7, Lcom/nemustech/regina/widgets/missednoti/CallLogReader$CallLogInfo;->mCallType:I

    .line 74
    iput v9, v7, Lcom/nemustech/regina/widgets/missednoti/CallLogReader$CallLogInfo;->mCallNew:I

    .line 75
    const-string v0, "number"

    invoke-interface {v6, v0}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v0

    invoke-interface {v6, v0}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v0

    iput-object v0, v7, Lcom/nemustech/regina/widgets/missednoti/CallLogReader$CallLogInfo;->mCallNumber:Ljava/lang/String;

    .line 76
    const-string v0, "_id"

    invoke-interface {v6, v0}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v0

    invoke-interface {v6, v0}, Landroid/database/Cursor;->getInt(I)I

    move-result v0

    iput v0, v7, Lcom/nemustech/regina/widgets/missednoti/CallLogReader$CallLogInfo;->mCallId:I

    .line 78
    new-instance v11, Ljava/text/SimpleDateFormat;

    const-string v0, "yyyy/MM/dd"

    invoke-direct {v11, v0}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;)V

    .line 79
    .local v11, sdf:Ljava/text/SimpleDateFormat;
    new-instance v0, Ljava/util/Date;

    const-string v2, "date"

    invoke-interface {v6, v2}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v2

    invoke-interface {v6, v2}, Landroid/database/Cursor;->getLong(I)J

    move-result-wide v2

    invoke-direct {v0, v2, v3}, Ljava/util/Date;-><init>(J)V

    invoke-virtual {v11, v0}, Ljava/text/SimpleDateFormat;->format(Ljava/util/Date;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, v7, Lcom/nemustech/regina/widgets/missednoti/CallLogReader$CallLogInfo;->mCallDate:Ljava/lang/String;

    .line 80
    invoke-interface {p1, v7}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 82
    .end local v11           #sdf:Ljava/text/SimpleDateFormat;
    :cond_3
    invoke-interface {v6}, Landroid/database/Cursor;->moveToNext()Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    move-result v0

    if-nez v0, :cond_2

    .line 86
    if-eqz v6, :cond_0

    invoke-interface {v6}, Landroid/database/Cursor;->close()V

    goto :goto_0

    .line 83
    .end local v1           #callLogUri:Landroid/net/Uri;
    .end local v7           #callLogInfo:Lcom/nemustech/regina/widgets/missednoti/CallLogReader$CallLogInfo;
    .end local v8           #callLogType:I
    .end local v9           #callNew:I
    :catch_0
    move-exception v0

    move-object v10, v0

    .line 84
    .local v10, e:Ljava/lang/Exception;
    :try_start_2
    invoke-virtual {v10}, Ljava/lang/Exception;->printStackTrace()V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    .line 86
    if-eqz v6, :cond_0

    invoke-interface {v6}, Landroid/database/Cursor;->close()V

    goto :goto_0

    .end local v10           #e:Ljava/lang/Exception;
    :catchall_0
    move-exception v0

    if-eqz v6, :cond_4

    invoke-interface {v6}, Landroid/database/Cursor;->close()V

    :cond_4
    throw v0
.end method
